<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
            String basePath = "http://" + request.getLocalAddr() + ":" + request.getLocalPort() + request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <title>${promptInfo.totalDescInfo}</title>
    <head>
	<script type="text/javascript">
	var counter=0;
	var jdata = {
		//ajax请求url
		url:'ajaxAction.action',
		//ajax提交方式
		type:'post',
		//ajax请求超时时长
		timeout:'60000',
		//ajax请求参数
		data:'',
		//请求数据类型，包括json和xml两种
		dataType:'json',
		//ajax请求完成后调用函数
		complete:function(request,textStatus){},
		//ajax请求成功调用函数
		success:function(jsonData,textStatus){
		}
	};
	$(document).ready(function(){
		$('#paramTable .opt_delete').each(function(){
			$(this).bind("click",clearTDContent);
		});
		$('#paramTable .opt_create').each(function(i){
			$(this).bind("click",addTDContent);
		});		
	});
	//创建新的参数添加控件
	function addTDContent(i){
		var val = $("#td_desc_0 input").val();
		var eles = $(".descClass");
		//var eles = document.getElementsByName("paramMap.parDesc");
		for(var i=0;i<eles.length;i++){
			if(eles[i].value==val){
				alert("参数描述不能重复");
				$("#td_desc_0 input").val("");
				return false;
			}
		}
		$(this).parent(".SkyTDLine").append(
				$("<a></a>")
				.attr("href","#")
				.attr("class","opt_delete").append(
				$("<img></img>")
				.attr("src","${pmsIndex.config_global_param.icon}")
				.attr("width","14")
				.attr("border","0")
				.attr("height","14")
			)
		);
		$(this).remove();
		var addContent =  showContent(i);
		$('#paramTable').append(addContent);
		$('#paramTable').html();
		$('#paramTable .opt_create').each(function(){
			$(this).bind("click",addTDContent);
		});
		$('#paramTable .opt_delete').each(function(){
			$(this).bind("click",clearTDContent);
		});
	}
	//删除所选的参数控件
	function clearTDContent(){
			if($(this).attr("id")){
				var p = 'code=${pmsIndex.config_global_param_delete.code}&paramMap.parID=' + $(this).attr("id");
				jdata = $.extend(jdata,{data:p});
				$.ajax(jdata);
				$(this).parent(".SkyTDLine").parent(".MeNewTDLine").remove();
			}else{
				$(this).parent(".SkyTDLine").parent(".MeNewTDLine").remove();
			}

		}
	function showContent(i){
		var $content = $("<tr></tr>").addClass("MeNewTDLine").attr("id","draw_"+i);
		$content.append($("<td></td>")
				.attr("class","SkyTDLine")
				.attr("align","center").append($("<input/>")
									   .attr("type","text")
									   .attr("name","paramMap.parDesc")
									   .attr("class","descClass")
									   .attr("id","parDesc")
									   .attr("style","width:200")
									   )
				);		
			$content.append($("<td></td>")
							.attr("class","SkyTDLine")
							.attr("align","center").append($("<input/>")
												   .attr("type","text")
												   .attr("name","paramMap.parName")
												   .attr("id","parName")
												   .attr("style","width:200")
												   )
							);
			$content.append($("<td></td>")
					.attr("class","SkyTDLine")
					.attr("align","center").append($("<input/>")
										   .attr("type","text")
										   .attr("name","paramMap.parValue")
										   .attr("id","parValue")
										   .attr("style","width:200")
										   )
					);

			$content.append(
						$("<td></td>")
						.attr("class","SkyTDLine")
						.attr("align","center")
						.append(
							$("<a></a>")
								.attr("href","#")
								.attr("class","opt_create").append(
								$("<img></img>")
								.attr("src","${pmsIndex.config_global_param_create.icon}")
								.attr("width","14")
								.attr("border","0")
								.attr("height","14")
							)
						)
			);
			return $content;
		}
	function dis()
	{
		document.getElementById("BtnOk").disabled=true;
		document.getElementById("actionForm").submit();
	}
</script>
</head>
<body>
<form name="actionForm" method="post" action="operateAction.action" id="actionForm">
<input type="hidden" value="name" name="logColumn" />
<input type="hidden" value="true" name="islog" />
<input type="hidden" name="code" id="code" value="${pmsIndex.config_global_param_create.code}"> 
<input type="hidden" name="imitateStep" value="${pmsIndex.config_global_param.imitationStep}"> 
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableC">
    <tr>
        <td class="tableCleft">&nbsp;</td>
        <td class="tableCcenter">
            <table width="100%" border="0" cellpadding="0" cellspacing="1" class="SkyTDLine">
                <tr>
                    <td class="SkyTDLine">
                        <table class="SkyTDLine" cellSpacing="1" cellPadding="0" width="95%" border="0" align="center">
                            <tr class="MeNewTDLine" align="center">
                                <td align="center">
                                    <table class="Ntable" id="paramTable" cellSpacing="1" cellPadding="0" width="100%" border="0">
                                        <tr class="MeNewTDLine">
                                            <td align="center" class="SkyTDLine" width="30%"><b>参数描述</b></td>
                                            <td align="center" class="SkyTDLine" width="30%"><b>参数名称</b></td>
                                            <td align="center" class="SkyTDLine" width="30%"><b>参数值</b></td>
											<td align="center" class="SkyTDLine" width="10%"><b>操作</b></td>
                                        </tr>
										<s:iterator value="initMap.paramInfo" id="paramList" status="ind">  
											<tr class="MeNewTDLine">
												<td id="td_name_${paramList.parDesc}"  class="SkyTDLine" align="center">
													<input type="text" name="paramMap.parDesc" id="parDesc" class='descClass' value="${paramList.parDesc}" style="width:200">
												</td>
												<td id="td_name_${paramList.parID}"  class="SkyTDLine" align="center">
													<input type="text" name="paramMap.parName" id="paraName" value="${paramList.parName}" style="width:200">
												</td>
												<td id="td_value_${paramList.parID}"  class="SkyTDLine" align="center">
													<input type="text"  name="paramMap.parValue" id="parValue" value="${paramList.parValue}" style="width:200">
												</td>
												<td id="td_oper_${paramList.parID}"  class="SkyTDLine" align="center">
													<a href="#" id="${paramList.parID}" class="opt_delete"><img src="<%=request.getContextPath()%>/${pmsIndex.config_global_param_delete.icon}" width="14" border="0" height="14"></img></a>
												</td>
											</tr>
									     </s:iterator>
											<tr class="MeNewTDLine">
												<td id="td_desc_0"  class="SkyTDLine" align="center">
													<input type="text" name="paramMap.parDesc" id="parDesc" style="width:200">
												</td>
												<td id="td_name_0"  class="SkyTDLine" align="center">
													<input type="text" name="paramMap.parName" id="paraName" style="width:200">
												</td>
												<td id="td_value_0"  class="SkyTDLine" align="center">
													<input type="text" name="paramMap.parValue" id="parValue" style="width:200">
												</td>
												<td id="td_oper_0"  class="SkyTDLine" align="center">
													<a href="#" id="0" class="opt_create" ><img src="<%=request.getContextPath()%>/${pmsIndex.config_global_param_create.icon}" width="14" border="0" height="14"></img></a>
												</td>
											</tr>					
                                      </table> 
                                  </td>
                              </tr>
								<tr class="MeNewTDLine" align="center">
									<td colSpan="2" class="SkyTDLine" height="20">
                                      <input type="button" name="BtnOk" value="保存" id="BtnOk" class="SkyButtonBlur" onMouseOut="this.className='SkyButtonBlur'" onMouseOver="this.className='SkyButtonFocus'" onclick="dis();" />
									</td>
								</tr>
                          </table>
                      </td>
                  </tr>
              </table>
          </td>
          <td class="tableCright">&nbsp;</td>
      </tr>
  </table>
</form>
</body>
</html>
